import {propTypes} from "@/utils/propTypes";
import {Pagination, TableColumn} from "@/components/DTable/src/Table/src/types/index";

export const myProps = {
    summaryname: propTypes.string.def(''),
    pageSize: propTypes.number.def(10),

    currentPage: propTypes.number.def(1),
    multipleSelection:propTypes.number.def(0),
        // 是否展示表格的工具栏
    showAction: propTypes.bool.def(false),
        // 是否所有的超出隐藏，优先级低于schema中的showOverflowTooltip,
    showOverflowTooltip: propTypes.bool.def(false),

        // parm: { type: Object as PropType<TableProps>, default: () => {} },
        // 表头
    columns: { type: Array as PropType<TableColumn[]>, default: () => [] },
    // 是否展示分页
    pagination: {type: Object as PropType<Pagination>, default: (): Pagination | undefined => undefined },
    // 仅对 type=selection 的列有效，类型为 Boolean，为 true 则会在数据更新之后保留之前选中的数据（需指定 row-key）
    reserveSelection: propTypes.bool.def(false),
        // 加载状态
    loading: propTypes.bool.def(false),
        // 是否叠加索引
    reserveIndex: propTypes.bool.def(false),
        // 对齐方式
    align: propTypes.string.validate((v: string) => ['left', 'center', 'right'].includes(v)).def('left'),
        // 表头对齐方式
    headerAlign: propTypes.string.validate((v: string) => ['left', 'center', 'right'].includes(v)).def('left'),
    data: {  type: Array as PropType<Recordable[]>,  default: () => []  },
    // 图片自动预览字段数组
    imagePreview: { type: Array as PropType<string[]>, default: () => [] },
    // 视频自动预览字段数组
    videoPreview: { type: Array as PropType<string[]>,  default: () => []  },
    height: propTypes.oneOfType([Number, String]),
    maxHeight: propTypes.oneOfType([Number, String]),
    stripe: propTypes.bool.def(true),
    border: propTypes.bool.def(true),
    size: { type: String as PropType<ComponentSize>, validator: (v: ComponentSize) => ['default', 'small', 'large'].includes(v), default: 'default' },
    fit: propTypes.bool.def(true),
    showHeader: propTypes.bool.def(true),
    highlightCurrentRow: propTypes.bool.def(true),
    currentRowKey: propTypes.oneOfType([Number, String]),
    // row-class-name, 类型为 (row: Recordable, rowIndex: number) => string | string
    rowClassName: { type: [Function, String] as PropType<(row: Recordable, rowIndex: number) => string | string>, default: '' },
    rowStyle: {  type: [Function, Object] as PropType<(row: Recordable, rowIndex: number) => Recordable | CSSProperties>, default: () => undefined },
    cellClassName: {
      type: [Function, String] as PropType<
        (row: Recordable, column: any, rowIndex: number) => string | string
      >,
      default: ''
    },
    cellStyle: {
      type: [Function, Object] as PropType<
        (row: Recordable, column: any, rowIndex: number) => Recordable | CSSProperties
      >,
      default: () => undefined
    },
    headerRowClassName: {
      type: [Function, String] as PropType<(row: Recordable, rowIndex: number) => string | string>,
      default: ''
    },
    headerRowStyle: {
      type: [Function, Object] as PropType<
        (row: Recordable, rowIndex: number) => Recordable | CSSProperties
      >,
      default: () => undefined
    },
    headerCellClassName: {
      type: [Function, String] as PropType<
        (row: Recordable, column: any, rowIndex: number) => string | string
      >,
      default: ''
    },
    headerCellStyle: {
      type: [Function, Object] as PropType<
        (row: Recordable, column: any, rowIndex: number) => Recordable | CSSProperties
      >,
      default: () => undefined
    },
    rowKey: propTypes.string.def('id'),
    emptyText: propTypes.string.def('No Data'),
    // sortable: propTypes.string.def('custom'),
    defaultExpandAll: propTypes.bool.def(false),
    expandRowKeys: {
      type: Array as PropType<string[]>,
      default: () => []
    },
    defaultSort: {
      type: Object as PropType<{ prop: string; order: string }>,
      default: () => ({})
    },
    tooltipEffect: {
      type: String as PropType<'dark' | 'light'>,
      default: 'dark'
    },
    tooltipOptions: {
      type: Object as PropType<
        Pick<
          ElTooltipProps,
          | 'effect'
          | 'enterable'
          | 'hideAfter'
          | 'offset'
          | 'placement'
          | 'popperClass'
          | 'popperOptions'
          | 'showAfter'
          | 'showArrow'
        >
      >,
      default: () => ({
        enterable: true,
        placement: 'top',
        showArrow: true,
        hideAfter: 200,
        popperOptions: { strategy: 'fixed' }
      })
    },
    showSummary: propTypes.bool.def(true),
    sumText: propTypes.string.def('Sum'),
    summaryMethod: {
      type: Function as PropType<(param: { columns: any[]; data: any[] }) => any[]>,
      default: () => undefined
    },
    spanMethod: {
      type: Function as PropType<
        (param: { row: any; column: any; rowIndex: number; columnIndex: number }) => any[]
      >,
      default: () => undefined
    },
    selectOnIndeterminate: propTypes.bool.def(true),
        indent: propTypes.number.def(16),
        lazy: propTypes.bool.def(false),
        load: {
        type: Function as PropType<(row: Recordable, treeNode: any, resolve: Function) => void>,
    default: () => undefined
    },
    treeProps: {
        type: Object as PropType<{ hasChildren?: string; children?: string; label?: string }>,
    default: () => ({ hasChildren: 'hasChildren', children: 'children', label: 'label' })
    },
    tableLayout: {
        type: String as PropType<'auto' | 'fixed'>,
    default: 'fixed'
    },
    scrollbarAlwaysOn: propTypes.bool.def(false),
        flexible: propTypes.bool.def(false),
        // 自定义内容
        customContent: propTypes.bool.def(false),
    cardBodyStyle: {
      type: Object as PropType<CSSProperties>,
      default: () => ({})
    },
    cardBodyClass: {
      type: String as PropType<string>,
      default: ''
    },
    cardWrapStyle: {
      type: Object as PropType<CSSProperties>,
      default: () => ({})
    },
    cardWrapClass: {
      type: String as PropType<string>,
      default: ''
    }
}
